package com.example.demoback.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

//接口同意返回包装类

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {
    private String code;
    private String msg;
    private Object data;

    public static Result success(){ //无返回数据成功提示
        return new Result(Constants.CODE_200, "成功",null);
    }

    public static Result success(Object data){
        return new Result(Constants.CODE_200, "数据返回成功", data);
    }
    public static Result success(Object data,String msg){
        return new Result(Constants.CODE_200, msg, data);
    }

    public static Result error(String code, String msg){
        return new Result(code, msg, null);
    }

    public static Result error(){
        return new Result(Constants.CODE_500, "系统错误", null);
    }

    public static Result error(String msg){
        return new Result(Constants.CODE_300, msg, null);
    }
    public static Result error(Data data ,String msg){
        return new Result(Constants.CODE_300, msg, data);
    }

    public static Result error1(){
        return new Result(Constants.CODE_300, "数据库同步异常", null);
    }
    public static Result error1(Object data){
        return new Result(Constants.CODE_300, "数据库同步异常", data);
    }

    public static Result error(boolean b, String msg) {
        return new Result(Constants.CODE_300, "数据库同步异常", b);
    }
}
